using Zhaoxi.Zhihu.Core.Common;

namespace Zhaoxi.Zhihu.Core.QuestionAggregate.Entites;

public class Answer:AuditWithUserEntity
{
   
    public string Content { get; set; } = null!;
    
    public int QuestionId { get; set; }
    public Question Question { get; set; } = null!;
    
    public int LikeCount { get; private set; }
    
    private readonly List<AnswerLike> _answerLikes = new();
    public IEnumerable<AnswerLike> AnswerLikes => _answerLikes;

    public int AddLike(AnswerLike answerLike)
    {
        LikeCount += 1;
        _answerLikes.Add(answerLike);
        return LikeCount;
    }

    public int RemoveLike(AnswerLike answerLike)
    {
        LikeCount -= 1;
        _answerLikes.Remove(answerLike);
        return LikeCount;
    }
}